<?php
class TestsController extends AppController {

	var $name = 'Tests';

	function index() {


/**
		// Create a blank image.
		$image = imagecreatetruecolor(400, 300);

//		imageantialias($image, true);

		// Select the background color.
		$bg = imagecolorallocate($image, 255, 255, 255);

		// Fill the background with the color selected above.
		imagefill($image, 0, 0, $bg);

		// Choose a color for the ellipse.
		$col_ellipse = imagecolorallocate($image, 221, 221, 221);

		// Draw the ellipse.
		imageellipse($image, 200, 150, 130, 120, $col_ellipse);

	//	header("Content-type: image/png");
	//	imagepng($image);
*/
	}

	function __detectRelations($type1 = null, $type2 = null) {
			$q1 = $this->__detectQuadra($type1);
			$q2 = $this->__detectQuadra($type2);

			$x = $this->__detectQuadraRelsations($q1, $q2);

			return abs($type1 - $type2) + $x;
	}

	function __detectQuadraRelsations($q1, $q2) {
		$x = abs($q1 - $q2);

		if ($x == 0) {
			$y = 1;
		} elseif ($x == 1) {
			$y = 1;
		} elseif ($x == 2) {
			$y = 1;
		} elseif ($x == 2) {
			$y = 1;
		}

		return $y;

	}

	function __detectQuadra($typeid) {
		$x = $typeid / 4;

		if ($x <= 1) {
			$q = 1;
		} elseif ($x > 1 && $x <= 2) {
			$q = 2;
		} elseif ($x > 2 && $x <= 3 ) {
			$q = 3;
		} elseif ($x > 3) {
			$q = 4;
		}
		return $q;
	}


	function image() {
		 header("Content-Type: image/jpeg");
		 $file = "/home/rhrn/P1000172.JPG";
		 $im = imagecreatefromjpeg($file);
		 //imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR);
		 imagefilter($im, IMG_FILTER_SELECTIVE_BLUR);
		 //imagefilter($im, IMG_FILTER_SMOOTH, 200);
		 //imagefilter($im, IMG_FILTER_PIXELATE, 3);
		 imagejpeg($im);  
	}

}
?>
